Skip to content

Instantly share code, notes, and snippets.

@sunmeat
sunmeat / main.cpp
Last active May 19, 2024 11:00
client server UDP C++ example
CLIENT SIDE:
#include <iostream>
#include <winsock2.h>
using namespace std;
#pragma comment(lib,"ws2_32.lib")
#pragma warning(disable:4996)
#define SERVER "127.0.0.1" // or "localhost" - ip address of UDP server
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Greek Yogurt 🥛</title>
</head>
<body>
<div class="container">
@raineorshine
raineorshine / java-exception-handling-best-practices.md
Last active May 19, 2024 10:57
5 Great Resources for Exception Handling Best Practices in Java

General Tip

"The trick is to catch exceptions at the proper layer, where your program can either meaningfully recover from the exception and continue without causing further errors, or provide the user with specific information, including instructions on how to recover from the error. When it is not practical for a method to do either of these, simply let the exception go so it can be caught later on and handled at the appropriate level."

Resources

Advantages of Exceptions
Excellent example of separating error-handling code from program logic

Three Rules for Effective Exception Handling
Longer explanation and case study of exception use, including the basic principles of "throw early" and "catch late". Clear and thorough.

@mikahimself
mikahimself / fem-deep-javascript-foundations-v3.md
Last active May 19, 2024 10:56
Notes from Deep JavaScript Foundations v3

Deep JavaScript Foundations v3

Types

Primitive types

In JavaScript, everything is NOT an object. ECMAScript language types are:

  • Undefined
  • Boolean
  • String
@vishal2376
vishal2376 / Place.kt
Last active May 19, 2024 10:54
Image Reflection with cool animation using Jetpack Compose
data class Place(
val name: String,
val resId: Int
)
@joshbuchea
joshbuchea / semantic-commit-messages.md
Last active May 19, 2024 10:52
Semantic Commit Messages

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

@AzimsTech
AzimsTech / foo.md
Last active May 19, 2024 10:52
xd

Configuring TMNet UniFi ISP through OpenWrt Web Interface

UniFi is a popular internet service provider in Malaysia, and OpenWrt is a free and open-source firmware for routers that allows for greater control and customization. This tutorial will guide you through the process of configuring UniFi on your OpenWrt router using the web interface.

Step 1: Connect to your OpenWrt router

Connect your computer to the router via Ethernet cable or Wi-Fi, and access the router's web interface by typing the IP address into your web browser's address bar. The default IP address for OpenWrt is 192.168.1.1.

Step 2: Navigate to Network Interfaces

@hakerdefo
hakerdefo / sources.list
Created June 11, 2023 18:47
Debian 12 "bookworm" complete sources.list
deb https://ftp.debian.org/debian/ bookworm contrib main non-free non-free-firmware
# deb-src https://ftp.debian.org/debian/ bookworm contrib main non-free non-free-firmware
deb https://ftp.debian.org/debian/ bookworm-updates contrib main non-free non-free-firmware
# deb-src https://ftp.debian.org/debian/ bookworm-updates contrib main non-free non-free-firmware
deb https://ftp.debian.org/debian/ bookworm-proposed-updates contrib main non-free non-free-firmware
# deb-src https://ftp.debian.org/debian/ bookworm-proposed-updates contrib main non-free non-free-firmware
deb https://ftp.debian.org/debian/ bookworm-backports contrib main non-free non-free-firmware
@RRethy
RRethy / gist:ad8a9a3b1112a48226ec3336fa981224
Last active May 19, 2024 10:48
Seamlessly editing remote files in (Neo)Vim with Netrw and scp

Seamlessly editing remote files in (Neo)Vim with Netrw and scp

Neovim and Vim both come bundled with a standard plugin called Netrw. Netrw acts a file explorer (similar to NERDTree), but more importantly has the ability to work with scp (as well as sftp, rcp, ftp, and lots of others :h netrw-nread) to let you edit files and browse directories that are hosted on a remote machine, inside of your local Vim instance.

This is useful since you are able to use your Vim setup and plugins without copying over your dotfiles to the remote machine. As well, since the file is copied to your local machine, there will be no delay when typing.

Setup

This is optional for Vim, but required for Neovim (check this Neovim issue explaining why).

@dhh
dhh / linux-setup.sh
Last active May 19, 2024 10:48
linux-setup.sh
# CLI
sudo apt update -y
sudo apt install -y \
git curl btop \
docker.io docker-buildx \
build-essential pkg-config autoconf bison rustc cargo clang \
libssl-dev libreadline-dev zlib1g-dev libyaml-dev libreadline-dev libncurses5-dev libffi-dev libgdbm-dev libjemalloc2 \
libvips imagemagick libmagickwand-dev mupdf mupdf-tools \
redis-tools sqlite3 libsqlite3-0 libmysqlclient-dev \
rbenv apache2-utils